The completed parameter list is seen below.
class Car
{
// instance variables
double startMiles; // Stating odometer reading
double endMiles; // Ending odometer reading
double gallons; // Gallons of gas used between the readings
// constructor
Car( double first, double last, double gals )
{
= first;
= last;
= gals;
}
// methods
}
In this constructor, the parameter list uses three parameters to match the three instance variables that will be initialized.
Note: In most classes there is NOT an exact match between the parameters of a constructor and the instance variables. There may be fewer (or more) parameters than instance variables.
Also, the constructor's parameters do not have to be in the same order as the instance variables (this might help keep things straight, but the compiler does not care).
Now fill in the assignment statements to complete the constructor.